package homework6;

public class Test5 {
    public static void main(String[] args) {
		Thread t1 = new Thread() {
		    //使用匿名内部类创建线程时要重写run方法
		    public void run(){
                Foo.dosome();
            }
		};
		//两种lambda表达式写法
//		Thread t1 = new Thread(()->Foo.dosome());
//		Thread t1 = new Thread(()->{Foo.dosome();});
		Thread t2 = new Thread() {
            public void run(){
                Foo.dosome();
            }
		};
		t1.start();
		t2.start();
    }
}
class Foo{
    public static void dosome() {
		synchronized (Foo.class) {
			System.out.println("hello!");
		}
    }
}

